1SAWinSta 2-------- 3I write a GUI appication, and the user may run it in task schedule. Since 4windows 2000/XP treat schedule task as a service, the schedule service can 5not be associated with interactive desktop object in the in 2 states 61) No user log on 72) Log on with another account. 8I write a test program, and find when the schedule service starts, the 9station/desktop will be "SAWinSta\Desktop" in both cases 10 11Is there any way to let schedule service associated with interactive desktop 12in these 2 cases? 13 14thanks 15------------------------------------------- 16 17Service-0x0-3e7$ 18---------------- 19By default Win32 services associated with non-visible windows station (for 20services which run in the local system account it is Service-0x0-3e7$) and they 21can't (without using special flag MB_SERVICE_NOTIFICATION or 22MB_DEFAULT_DESKTOP_ONLY in the MessageBox function) interact with user. 23However, you may configure a service to have GUI capabilities. Just set Type 24field of the registry service entry equal SERVICE_INTERACTIVE_PROCESS. When 25this key is specified SCM will connect the service with WinSta0 instead 26Service-0x0-3e7$ and it will alow to display windows and dialog boxes. 27 28------------------------------------------------- 29 30WinSta0 31------- 32 33-The one-and-only interactive WinSta. 34-No other winsta can be visible/active. 35-Only WinSta0 can receive input. 36-All other WinSta's are invisible/non-interactive WinStas. 37 38What good is a invisible WinSta? Its used for running services in thus services cant 39interact with the user. 40 41There are limits to what u can do in a invisible WinSta. 42-Bitblt wont work for instance, since nothing is really displayed in a invisible WinSta (to save resources). 43 No point in using GDI resources for stuff noone can see. 44-SendInput wont work 45 46 47 48--------------------------------------------------- 49 MORE INFORMATION 50 51A Window station can either be interactive or noninteractive. (At the moment on Windows NT 3.51 and 4.0, only "Winsta0" can be an interactive Window station.) Any Desktops created on the interactive Window station will have the ability to become active. An active Desktop encompasses the ability for user objects (such as windows and dialog boxes) created on the Desktop to be visible to the interactively logged-on user (that is, the user who logs on the system via CTRL-ALT-DELETE) and receive user input. 52 53When the interactively logged-on user launches any processes, these processes are associated with the "default" Desktop in the "Winsta0" Window station. The "default" Desktop is considered the active Desktop. A process on the active Desktop could switch Desktops such that another Desktop becomes the active Desktop such as the "Winlogon" Desktop. Only one Desktop can be the active Desktop at any one time. 54 55Desktops associated with a noninteractive Window station can create user objects. These objects will never be visible to the interactively logged-on user and will never receive any user input. If you have a noninteractive Service running in the LocalSystem account, any user objects created by the service will not be visible to the interactively logged-on user. In addition, any processes launched by the service will also not be visible. 56If our desktop has the same name as the active one, we are running on the 57active (input) desktop. This is true because desktops have exactly one 58name each, and within a window station, desktop names must be unique 59---------------------------------------------------------------- 60 61Process closing window station with CloseWindowStation can't be assigned to the window station 62 it is closing. 63 64 65The reason is that each session has its own CSRSS, as well as instanced 66win32k.sys data. So in each session, you basically have a complete copy of 67Windows that doesn't know about the existance of any other copy. You're not 68just on a different desktop/windowstation when you're in a different 69session. 70 71 72Lawrence, you are wrong. HWNDs are valid throughout the whole 73windowstation, not only the creating process. That's because they 74are pointers, but not in your address space... 75 76 77The CreateDesktop function creates a new desktop on the window station associated with the calling process. 78 79PROCESS: 80-every w32 process is associated with a WindowStation 81-can move between window stations (well, with strict limitations i would guess eg. what if 82 windows have been created and is using the winsta heap? or can multiple winsta heaps be mapped into 83 one process?? ) 84 85THREADS: 86-can only enumerate windows on its desktop (but u can easely switch to a different desk) 87-every w32 thread is associated with a Desktop 88-Threads can switch between desktops, and windows are created on the thread's current desktop 89 (a thread can have windows on multiple desktops? IS THIS REALLY TRUE?) 90 91DESKTOP: 92-owns windows 93-Only one desktop at a time can interact with the user, and that desktop must necessarily 94be associated with Winsta0 95-Only one desktop is visible to the user and only one can receives input at any time 96-contain a logical display surface 97-contin windows (or a pointer to the desktop window) 98-contain menus 99-contain hooks 100-holds UI objects, such as windows, menus, and hooks 101-Once a window is created it cannot move between desktops 102 103SESSION: 104-session = win32k instance 105-Every session contains one or more windows stations 106-A given login session has only one window station with access to user interactions 107(term server has multiple login sessions) 108-each logon session is associated with a window station 109 110WINDOW STATION: 111-only Winsta0 has access to the display 112-Only one window station, called Winsta0, can interact with the user display, keyboard, mouse 113-is a secure object 114-Only the interactive window station WinSta0, can display 115 output or receive input. Other window stations are used by "services" 116 (but cant u switch winsta?? so a noninteractive winsta becomes active?) 117-contains a set of global atoms 118-contains a clipboard 119-contains a set of desktop objects 120-contains handle table(s) (handles are valid throughout the whole windowstation, not only the creating process) 121-contain heaps (pointer(s) to the section heap(s) shared between user32/gdi32/win32k) 122-A Windows 2000 session will have several windows stations, one assigned to the logon session 123 of the interactive user, and others assigned to the Winlogon process, the secure screen saver 124 process, and any service that runs in a security context other than that of the interactive user. 125 126 The interactive window station assigned to the logon session of the interactive user also contains 127 the keyboard, mouse, and display device. The interactive window station is visible to the user and 128 can receive input from the user. All other window stations are noninteractive, which means that 129 they cannot be made visible to the user, and cannot receive user input. 130 131WINDOWS 132-is owned by a desktop 133-windows are tied to the window station where they started 134-u cant move windows between desktops either 135 136The system associates a desktop with a thread when that thread is created 137The desktop associated with a thread must be on the window station associated with the thread's process. 138A thread can use the SetThreadDesktop function to change its desktop. 139The GetThreadDesktop function retrieves a handle to the desktop associated with a specified thread. 140 141The calling process must have an associated window station, either assigned by the system at process creation time or set by SetProcessWindowStation. A desktop is a secure object contained within a window station object. 142 143 144There can be several window stations in the system but only one of them can 145be the interactive window station. That is the only windowstation whose 146processes can communicate with the user (it has a visible desktop and can 147receive mouse and keyboard input). A desktop lives inside a windowstation 148and provides a display to the user. Only one desktop can be the active 149desktop for a particular windowstation at any time. Furthermore only a 150desktop that lives inside the interactive windowstation and is the currently 151active desktop for that windowstation is visible to the user. On your 152average Windows NT system there are at least 3 desktops inside the 153interactive windowstation: the 'shell', winlogon and the screensaver. Each 154process that runs on your system (and hence services as well) run inside a 155windowstation and each thread in that process runs in the same windowstation 156but can run in a different desktop. 157